]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
js: Use one-shot idle/timeout functions
authorFlorian Müllner <fmuellner@gnome.org>
Fri, 31 Oct 2025 17:14:14 +0000 (18:14 +0100)
committerMarge Bot <marge-bot@gnome.org>
Thu, 29 Jan 2026 15:16:05 +0000 (15:16 +0000)
gjs now provides overrides for GLib's one-shot idle/timeout
functions, so use them to save a bit of code and clearly
indicate that a callback is only invoked once.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3947>

41 files changed:
js/dbusServices/dbusService.js
js/dbusServices/extensions/extensionPrefsDialog.js
js/gdm/loginDialog.js
js/gdm/util.js
js/misc/breakManager.js
js/misc/ibusManager.js
js/misc/inputMethod.js
js/misc/timeLimitsManager.js
js/portalHelper/main.js
js/ui/altTab.js
js/ui/appDisplay.js
js/ui/background.js
js/ui/components/automountManager.js
js/ui/components/polkitAgent.js
js/ui/dash.js
js/ui/dnd.js
js/ui/extensionSystem.js
js/ui/init.js
js/ui/keyboard.js
js/ui/lookingGlass.js
js/ui/magnifier.js
js/ui/main.js
js/ui/messageTray.js
js/ui/osdWindow.js
js/ui/overview.js
js/ui/panel.js
js/ui/screenShield.js
js/ui/screenshot.js
js/ui/scripting.js
js/ui/search.js
js/ui/status/accessibility.js
js/ui/status/backgroundApps.js
js/ui/status/bluetooth.js
js/ui/status/remoteAccess.js
js/ui/status/thunderbolt.js
js/ui/status/volume.js
js/ui/switcherPopup.js
js/ui/windowManager.js
js/ui/workspace.js
js/ui/workspaceSwitcherPopup.js
js/ui/workspaceThumbnail.js

index 85ed0d9ad02b345f69a7a3bf8c231de63aef155b..37677f4a5aa8216943ab6c6468c3fc81b7fd74f0 100644 (file)
@@ -120,13 +120,11 @@ export class ServiceImplementation {
         if (this._shutdownTimeoutId)
             GLib.source_remove(this._shutdownTimeoutId);
 
-        this._shutdownTimeoutId = GLib.timeout_add_seconds(
+        this._shutdownTimeoutId = GLib.timeout_add_seconds_once(
             GLib.PRIORITY_DEFAULT, IDLE_SHUTDOWN_TIME,
             () => {
                 this._shutdownTimeoutId = 0;
                 this._maybeShutdown();
-
-                return GLib.SOURCE_REMOVE;
             });
     }
 
index fbd17bd52c13ddcd6a0066fbe64e3634c2e0370c..24c32075d9ce5b717e900e2e7fb20134857a223d 100644 (file)
@@ -52,10 +52,9 @@ export class ExtensionPrefsDialog extends Adw.PreferencesWindow {
 
     set_titlebar() {
         // intercept fatal libadwaita error, show error page instead
-        GLib.idle_add(GLib.PRIORITY_DEFAULT, () => {
+        GLib.idle_add_once(GLib.PRIORITY_DEFAULT, () => {
             this._showErrorPage(
                 new Error('set_titlebar() is not supported for Adw.Window'));
-            return GLib.SOURCE_REMOVE;
         });
     }
 
index 4441834f27dab668ebcbc2ba5f006a0116c81ce4..70b68e304a172fda3805d8c24341101240232f34 100644 (file)
@@ -904,7 +904,7 @@ export const LoginDialog = GObject.registerClass({
                     }
                 });
         } else {
-            const id = GLib.idle_add(GLib.PRIORITY_DEFAULT, this._loadUserList.bind(this));
+            const id = GLib.idle_add_once(GLib.PRIORITY_DEFAULT, this._loadUserList.bind(this));
             GLib.Source.set_name_by_id(id, '[gnome-shell] _loadUserList');
         }
     }
@@ -1229,11 +1229,10 @@ export const LoginDialog = GObject.registerClass({
             }
         }, conflictingSessionDialog);
 
-        const closeDialogTimeoutId = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, _CONFLICTING_SESSION_DIALOG_TIMEOUT, () => {
+        const closeDialogTimeoutId = GLib.timeout_add_seconds_once(GLib.PRIORITY_DEFAULT, _CONFLICTING_SESSION_DIALOG_TIMEOUT, () => {
             this._notifyConflictingSessionDialogClosed();
             conflictingSessionDialog.close();
             this._authPrompt.reset();
-            return GLib.SOURCE_REMOVE;
         });
 
         conflictingSessionDialog.connect('closed', () => {
@@ -1321,11 +1320,10 @@ export const LoginDialog = GObject.registerClass({
     _blockTimedLoginUntilIdle() {
         const hold = new Batch.Hold();
 
-        this._timedLoginIdleTimeOutId = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, _TIMED_LOGIN_IDLE_THRESHOLD,
+        this._timedLoginIdleTimeOutId = GLib.timeout_add_seconds_once(GLib.PRIORITY_DEFAULT, _TIMED_LOGIN_IDLE_THRESHOLD,
             () => {
                 this._timedLoginIdleTimeOutId = 0;
                 hold.release();
-                return GLib.SOURCE_REMOVE;
             });
         GLib.Source.set_name_by_id(this._timedLoginIdleTimeOutId, '[gnome-shell] this._timedLoginIdleTimeOutId');
         return hold;
@@ -1509,7 +1507,7 @@ export const LoginDialog = GObject.registerClass({
 
     _loadUserList() {
         if (this._userListLoaded)
-            return GLib.SOURCE_REMOVE;
+            return;
 
         this._userListLoaded = true;
 
@@ -1536,8 +1534,6 @@ export const LoginDialog = GObject.registerClass({
                     this._userList.addUser(user);
                 this._updateDisableUserList();
             }, this);
-
-        return GLib.SOURCE_REMOVE;
     }
 
     activate() {
index e9262b138cca1af1079b653e840aae9a28ae3c27..f762b79ec220f5d9a7d2785093924e7938c3b3a6 100644 (file)
@@ -291,7 +291,7 @@ export class ShellUserVerifier extends Signals.EventEmitter {
         delete this._currentMessageExtraInterval;
         this.emit('show-message', message.serviceName, message.text, message.type);
 
-        this._messageQueueTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT,
+        this._messageQueueTimeoutId = GLib.timeout_add_once(GLib.PRIORITY_DEFAULT,
             message.interval + (this._currentMessageExtraInterval | 0), () => {
                 this._messageQueueTimeoutId = 0;
 
@@ -301,8 +301,6 @@ export class ShellUserVerifier extends Signals.EventEmitter {
                 } else {
                     this.finishMessageQueue();
                 }
-
-                return GLib.SOURCE_REMOVE;
             });
         GLib.Source.set_name_by_id(this._messageQueueTimeoutId, '[gnome-shell] this._queueMessageTimeout');
     }
@@ -765,12 +763,11 @@ export class ShellUserVerifier extends Signals.EventEmitter {
                     GLib.source_remove(this._fingerprintFailedId);
 
                 const cancellable = this._cancellable;
-                this._fingerprintFailedId = GLib.timeout_add(GLib.PRIORITY_DEFAULT,
+                this._fingerprintFailedId = GLib.timeout_add_once(GLib.PRIORITY_DEFAULT,
                     FINGERPRINT_ERROR_TIMEOUT_WAIT, () => {
                         this._fingerprintFailedId = 0;
                         if (!cancellable.is_cancelled())
                             this._verificationFailed(serviceName, false);
-                        return GLib.SOURCE_REMOVE;
                     });
             }
         }
index 18ebdf0a28e2fe3ff11ddef9b78432fdca21d847..a72b9c109a550e17077db946fd3bade60c77c3e7 100644 (file)
@@ -805,7 +805,7 @@ class BreakDispatcher extends GObject.Object {
 
                 if (this._countdownTimerId !== 0)
                     GLib.source_remove(this._countdownTimerId);
-                this._countdownTimerId = GLib.timeout_add_seconds(
+                this._countdownTimerId = GLib.timeout_add_seconds_once(
                     GLib.PRIORITY_DEFAULT,
                     countdownStart, () => {
                         if (this._countdownOsd == null) {
@@ -814,7 +814,6 @@ class BreakDispatcher extends GObject.Object {
                                 () => (this._countdownOsd = null));
                         }
                         this._countdownTimerId = 0;
-                        return GLib.SOURCE_REMOVE;
                     });
             }
 
@@ -1035,11 +1034,10 @@ class BreakNotificationSource extends GObject.Object {
 
         console.debug(`BreakNotificationSource: Scheduling notification state update in ${timeoutSeconds}s`);
 
-        this._timerId = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, timeoutSeconds, () => {
+        this._timerId = GLib.timeout_add_seconds_once(GLib.PRIORITY_DEFAULT, timeoutSeconds, () => {
             this._timerId = 0;
             console.debug('BreakNotificationSource: Scheduled notification state update');
             this._updateState();
-            return GLib.SOURCE_REMOVE;
         });
     }
 
index a9178805f495817bd4505d32e8a4ee78f0c00d34..d9995b81a7ab6feb6ae0b0ca461a2ff6792a30bd 100644 (file)
@@ -329,7 +329,7 @@ class IBusManager extends Signals.EventEmitter {
         }
 
         this._preloadEnginesId =
-            GLib.timeout_add_seconds(
+            GLib.timeout_add_seconds_once(
                 GLib.PRIORITY_DEFAULT,
                 this._PRELOAD_ENGINES_DELAY_TIME,
                 () => {
@@ -339,7 +339,6 @@ class IBusManager extends Signals.EventEmitter {
                         this._cancellable,
                         null);
                     this._preloadEnginesId = 0;
-                    return GLib.SOURCE_REMOVE;
                 });
     }
 
index f15eb2e398458c2859e24b6d8ceb74c2724b6530..f0c39e77b35bb0c3f46fcc6335093991f5eb8aa2 100644 (file)
@@ -219,10 +219,9 @@ export const InputMethod = GObject.registerClass({
             this._preeditStr = null;
         }
 
-        this._hidePanelId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, HIDE_PANEL_TIME, () => {
+        this._hidePanelId = GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, HIDE_PANEL_TIME, () => {
             this.set_input_panel_state(Clutter.InputPanelState.OFF);
             this._hidePanelId = 0;
-            return GLib.SOURCE_REMOVE;
         });
     }
 
index abaf3ba24922a8a25a1ea83dbce2613599fb5ad4..f980477bc82a535737501afba8583486bb6d30da 100644 (file)
@@ -1336,11 +1336,10 @@ class TimeLimitsNotificationSource extends GObject.Object {
 
         console.debug(`TimeLimitsNotificationSource: Scheduling notification state update in ${timeoutSeconds}s`);
 
-        this._timerId = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, timeoutSeconds, () => {
+        this._timerId = GLib.timeout_add_seconds_once(GLib.PRIORITY_DEFAULT, timeoutSeconds, () => {
             this._timerId = 0;
             console.debug('TimeLimitsNotificationSource: Scheduled notification state update');
             this._updateState();
-            return GLib.SOURCE_REMOVE;
         });
     }
 
index a3a802217ddddabd8b519639d8683326d68de5cf..7004a327949fff7adefddb06e869f3b36eae7ced 100644 (file)
@@ -271,10 +271,9 @@ class PortalWindow extends Gtk.ApplicationWindow {
                 const seconds =
                     (CONNECTIVITY_RECHECK_RATELIMIT_TIMEOUT - timeSinceLastRecheck) /
                     GLib.USEC_PER_SEC;
-                this._recheckTimeoutId = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, seconds, () => {
+                this._recheckTimeoutId = GLib.timeout_add_seconds_once(GLib.PRIORITY_DEFAULT, seconds, () => {
                     this._statusChangedCallback(PortalHelperResult.RECHECK);
                     this._recheckTimeoutId = 0;
-                    return GLib.SOURCE_REMOVE;
                 });
             }
         }
index 91020e6d3fbc03c97ad871c54fb92ee994ee15db..1a6c705034df239cc1b71fde778c1aea821d945b 100644 (file)
@@ -349,7 +349,7 @@ class AppSwitcherPopup extends SwitcherPopup.SwitcherPopup {
             this._thumbnails.highlight(window, forceAppFocus);
         } else if (this._items[this._selectedIndex].cachedWindows.length > 1 &&
                    !forceAppFocus) {
-            this._thumbnailTimeoutId = GLib.timeout_add(
+            this._thumbnailTimeoutId = GLib.timeout_add_once(
                 GLib.PRIORITY_DEFAULT,
                 THUMBNAIL_POPUP_TIME,
                 this._timeoutPopupThumbnails.bind(this));
@@ -362,7 +362,6 @@ class AppSwitcherPopup extends SwitcherPopup.SwitcherPopup {
             this._createThumbnails();
         this._thumbnailTimeoutId = 0;
         this._thumbnailsFocused = false;
-        return GLib.SOURCE_REMOVE;
     }
 
     _destroyThumbnails() {
@@ -826,14 +825,13 @@ class AppSwitcher extends SwitcherPopup.SwitcherList {
 
         if (this._altTabPopup.thumbnailsVisible) {
             this._delayedHighlighted = index;
-            this._mouseTimeOutId = GLib.timeout_add(
+            this._mouseTimeOutId = GLib.timeout_add_once(
                 GLib.PRIORITY_DEFAULT,
                 APP_ICON_HOVER_TIMEOUT,
                 () => {
                     this._enterItem(index);
                     this._delayedHighlighted = -1;
                     this._mouseTimeOutId = 0;
-                    return GLib.SOURCE_REMOVE;
                 });
             GLib.Source.set_name_by_id(this._mouseTimeOutId, '[gnome-shell] this._enterItem');
         } else {
index 5a29634864b290d6139fdb4dc033d1e61de02821..a1de2a87d7900f1ccf404f67b202096f6fb88384 100644 (file)
@@ -691,11 +691,10 @@ var BaseAppView = GObject.registerClass({
         this.goToPage(nextPage);
 
         this._canScroll = false;
-        this._scrollTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT,
+        this._scrollTimeoutId = GLib.timeout_add_once(GLib.PRIORITY_DEFAULT,
             SCROLL_TIMEOUT_TIME, () => {
                 this._canScroll = true;
                 this._scrollTimeoutId = 0;
-                return GLib.SOURCE_REMOVE;
             });
 
         return Clutter.EVENT_STOP;
@@ -797,12 +796,11 @@ var BaseAppView = GObject.registerClass({
                 position,
                 source,
                 destroyId: source.connect('destroy', () => this._removeDelayedMove()),
-                timeoutId: GLib.timeout_add(GLib.PRIORITY_DEFAULT,
+                timeoutId: GLib.timeout_add_once(GLib.PRIORITY_DEFAULT,
                     DELAYED_MOVE_TIMEOUT, () => {
                         this._moveItem(source, page, position);
                         this._delayedMoveData.timeoutId = 0;
                         this._removeDelayedMove();
-                        return GLib.SOURCE_REMOVE;
                     }),
             };
         }
@@ -909,14 +907,13 @@ var BaseAppView = GObject.registerClass({
         const {targetActor} = dragEvent;
 
         this._dragPageSwitchInitialTimeoutId =
-            GLib.timeout_add(GLib.PRIORITY_DEFAULT, DRAG_PAGE_SWITCH_INITIAL_TIMEOUT, () => {
+            GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, DRAG_PAGE_SWITCH_INITIAL_TIMEOUT, () => {
                 const direction = targetActor === this._prevPageIndicator ? -1 : 1;
 
                 this.goToPage(this._grid.currentPage + direction);
                 this._setupDragPageSwitchRepeat(direction);
 
                 delete this._dragPageSwitchInitialTimeoutId;
-                return GLib.SOURCE_REMOVE;
             });
     }
 
@@ -2815,10 +2812,9 @@ export const AppFolderDialog = GObject.registerClass({
             return;
 
         this._popdownTimeoutId =
-            GLib.timeout_add(GLib.PRIORITY_DEFAULT, POPDOWN_DIALOG_TIMEOUT, () => {
+            GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, POPDOWN_DIALOG_TIMEOUT, () => {
                 this._popdownTimeoutId = 0;
                 this.popdown();
-                return GLib.SOURCE_REMOVE;
             });
     }
 
@@ -3115,11 +3111,10 @@ export const AppIcon = GObject.registerClass({
                 return;
 
             this._folderPreviewId =
-                GLib.timeout_add(GLib.PRIORITY_DEFAULT, 500, () => {
+                GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, 500, () => {
                     this.add_style_pseudo_class('drop');
                     this._showFolderPreview();
                     this._folderPreviewId = 0;
-                    return GLib.SOURCE_REMOVE;
                 });
         } else {
             if (this._folderPreviewId > 0) {
index d5fdc9bc4c7a371cb146df5ce2ed994f2f8d6131..09edeb1bec4567a167d2272d4be98c3792fa4b35 100644 (file)
@@ -177,9 +177,8 @@ class BackgroundCache extends Signals.EventEmitter {
         let animation = this._animations[params.settingsSchema];
         if (animation && _fileEqual0(animation.file, params.file)) {
             if (params.onLoaded) {
-                const id = GLib.idle_add(GLib.PRIORITY_DEFAULT, () => {
+                const id = GLib.idle_add_once(GLib.PRIORITY_DEFAULT, () => {
                     params.onLoaded(this._animations[params.settingsSchema]);
-                    return GLib.SOURCE_REMOVE;
                 });
                 GLib.Source.set_name_by_id(id, '[gnome-shell] params.onLoaded');
             }
@@ -192,9 +191,8 @@ class BackgroundCache extends Signals.EventEmitter {
             this._animations[params.settingsSchema] = animation;
 
             if (params.onLoaded) {
-                const id = GLib.idle_add(GLib.PRIORITY_DEFAULT, () => {
+                const id = GLib.idle_add_once(GLib.PRIORITY_DEFAULT, () => {
                     params.onLoaded(this._animations[params.settingsSchema]);
-                    return GLib.SOURCE_REMOVE;
                 });
                 GLib.Source.set_name_by_id(id, '[gnome-shell] params.onLoaded');
             }
@@ -313,10 +311,9 @@ const Background = GObject.registerClass({
         if (this._changedIdleId)
             return;
 
-        this._changedIdleId = GLib.idle_add(GLib.PRIORITY_DEFAULT, () => {
+        this._changedIdleId = GLib.idle_add_once(GLib.PRIORITY_DEFAULT, () => {
             this._changedIdleId = 0;
             this.emit('bg-changed');
-            return GLib.SOURCE_REMOVE;
         });
         GLib.Source.set_name_by_id(this._changedIdleId,
             '[gnome-shell] Background._emitChangedSignal');
@@ -343,9 +340,8 @@ const Background = GObject.registerClass({
         if (this._cancellable?.is_cancelled())
             return;
 
-        const id = GLib.idle_add(GLib.PRIORITY_DEFAULT, () => {
+        const id = GLib.idle_add_once(GLib.PRIORITY_DEFAULT, () => {
             this.emit('loaded');
-            return GLib.SOURCE_REMOVE;
         });
         GLib.Source.set_name_by_id(id, '[gnome-shell] Background._setLoaded Idle');
     }
@@ -449,12 +445,11 @@ const Background = GObject.registerClass({
         if (interval > GLib.MAXUINT32)
             return;
 
-        this._updateAnimationTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT,
+        this._updateAnimationTimeoutId = GLib.timeout_add_once(GLib.PRIORITY_DEFAULT,
             interval,
             () => {
                 this._updateAnimationTimeoutId = 0;
                 this._updateAnimation();
-                return GLib.SOURCE_REMOVE;
             });
         GLib.Source.set_name_by_id(this._updateAnimationTimeoutId, '[gnome-shell] this._updateAnimation');
     }
@@ -544,9 +539,8 @@ export const SystemBackground = GObject.registerClass({
         });
         this.content.background = _systemBackground;
 
-        const id = GLib.idle_add(GLib.PRIORITY_DEFAULT, () => {
+        const id = GLib.idle_add_once(GLib.PRIORITY_DEFAULT, () => {
             this.emit('loaded');
-            return GLib.SOURCE_REMOVE;
         });
         GLib.Source.set_name_by_id(id, '[gnome-shell] SystemBackground.loaded');
     }
@@ -818,9 +812,8 @@ export class BackgroundManager extends Signals.EventEmitter {
 
         let loadedSignalId;
         if (background.isLoaded) {
-            GLib.idle_add(GLib.PRIORITY_DEFAULT, () => {
+            GLib.idle_add_once(GLib.PRIORITY_DEFAULT, () => {
                 this.emit('loaded');
-                return GLib.SOURCE_REMOVE;
             });
         } else {
             loadedSignalId = background.connect('loaded', () => {
index ed895b536b8f7ee008f5e7f9fedbd90621cde983..5ea1e2e12baa8eb8db69a25014c6b627447b8621 100644 (file)
@@ -36,7 +36,7 @@ class AutomountManager {
             'drive-disconnected', this._onDriveDisconnected.bind(this),
             'drive-eject-button', this._onDriveEjectButton.bind(this), this);
 
-        this._mountAllId = GLib.idle_add(GLib.PRIORITY_DEFAULT, this._startupMountAll.bind(this));
+        this._mountAllId = GLib.idle_add_once(GLib.PRIORITY_DEFAULT, this._startupMountAll.bind(this));
         GLib.Source.set_name_by_id(this._mountAllId, '[gnome-shell] this._startupMountAll');
     }
 
@@ -68,7 +68,6 @@ class AutomountManager {
         });
 
         this._mountAllId = 0;
-        return GLib.SOURCE_REMOVE;
     }
 
     _onDriveConnected() {
@@ -244,10 +243,9 @@ class AutomountManager {
     }
 
     _allowAutorunExpire(volume) {
-        const id = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, AUTORUN_EXPIRE_TIMEOUT_SECS, () => {
+        const id = GLib.timeout_add_seconds_once(GLib.PRIORITY_DEFAULT, AUTORUN_EXPIRE_TIMEOUT_SECS, () => {
             volume.allowAutorun = false;
             delete volume._allowAutorunExpireId;
-            return GLib.SOURCE_REMOVE;
         });
         volume._allowAutorunExpireId = id;
         GLib.Source.set_name_by_id(id, '[gnome-shell] volume.allowAutorun');
index c1566c2631777a9a5342bee7632273c5e9a5b83d..68ee8dbb353903135e04996f92d9370c99cc2c8d 100644 (file)
@@ -334,17 +334,15 @@ const AuthenticationDialog = GObject.registerClass({
             this._sessionRequestTimeoutId = 0;
 
             if (this.state !== ModalDialog.State.OPENED)
-                return GLib.SOURCE_REMOVE;
+                return;
 
             this._passwordEntry.hide();
             this._cancelButton.grab_key_focus();
             this._okButton.reactive = false;
-
-            return GLib.SOURCE_REMOVE;
         };
 
         if (delay) {
-            this._sessionRequestTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, delay, resetDialog);
+            this._sessionRequestTimeoutId = GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, delay, resetDialog);
             GLib.Source.set_name_by_id(this._sessionRequestTimeoutId, '[gnome-shell] this._sessionRequestTimeoutId');
         } else {
             resetDialog();
index d3a3080f06e4b3c652b8fb056d8f5428c12a4917..1df9414b4357679cffe58db72eeccb600214dfbd 100644 (file)
@@ -546,12 +546,11 @@ export const Dash = GObject.registerClass({
         if (shouldShow) {
             if (this._showLabelTimeoutId === 0) {
                 const timeout = this._labelShowing ? 0 : DASH_ITEM_HOVER_TIMEOUT;
-                this._showLabelTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, timeout,
+                this._showLabelTimeoutId = GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, timeout,
                     () => {
                         this._labelShowing = true;
                         item.showLabel();
                         this._showLabelTimeoutId = 0;
-                        return GLib.SOURCE_REMOVE;
                     });
                 GLib.Source.set_name_by_id(this._showLabelTimeoutId, '[gnome-shell] item.showLabel');
                 if (this._resetHoverTimeoutId > 0) {
@@ -565,11 +564,10 @@ export const Dash = GObject.registerClass({
             this._showLabelTimeoutId = 0;
             item.hideLabel();
             if (this._labelShowing) {
-                this._resetHoverTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, DASH_ITEM_HOVER_TIMEOUT,
+                this._resetHoverTimeoutId = GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, DASH_ITEM_HOVER_TIMEOUT,
                     () => {
                         this._labelShowing = false;
                         this._resetHoverTimeoutId = 0;
-                        return GLib.SOURCE_REMOVE;
                     });
                 GLib.Source.set_name_by_id(this._resetHoverTimeoutId, '[gnome-shell] this._labelShowing');
             }
index d769d18456f8ca0019043c2c8df862926baeddf5..071dc1c0df46d6f919a854ebd3201c2f50318a55 100644 (file)
@@ -333,7 +333,7 @@ class _Draggable extends Signals.EventEmitter {
                 if (result !== DragMotionResult.CONTINUE) {
                     this._updateCursor(DRAG_CURSOR_MAP[result]);
                     dragEvent.targetActor.disconnect(targetActorDestroyHandlerId);
-                    return GLib.SOURCE_REMOVE;
+                    return;
                 }
             }
         }
@@ -353,20 +353,19 @@ class _Draggable extends Signals.EventEmitter {
                     0);
                 if (result !== DragMotionResult.CONTINUE) {
                     this._updateCursor(DRAG_CURSOR_MAP[result]);
-                    return GLib.SOURCE_REMOVE;
+                    return;
                 }
             }
             target = target.get_parent();
         }
         this._updateCursor(Clutter.CursorType.NO_DROP);
-        return GLib.SOURCE_REMOVE;
     }
 
     _queueUpdateDragHover() {
         if (this._updateHoverId)
             return;
 
-        this._updateHoverId = GLib.idle_add(GLib.PRIORITY_DEFAULT,
+        this._updateHoverId = GLib.idle_add_once(GLib.PRIORITY_DEFAULT,
             this._updateDragHover.bind(this));
         GLib.Source.set_name_by_id(this._updateHoverId, '[gnome-shell] this._updateDragHover');
     }
index 1dc94b40b65ea39129034d3370ce92646fdeff3f..8a10c5c5be6a5948149a88e20b1e2691a67e571c 100644 (file)
@@ -65,11 +65,10 @@ export class ExtensionManager extends Signals.EventEmitter {
         const shutdownId = global.connect('shutdown',
             () => disableFile.delete(null));
 
-        GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, 60, () => {
+        GLib.timeout_add_seconds_once(GLib.PRIORITY_DEFAULT, 60, () => {
             global.disconnect(shutdownId);
 
             disableFile.delete(null);
-            return GLib.SOURCE_REMOVE;
         });
 
         this._installExtensionUpdates();
index 735a367bbeb1f00ea11ea87576f8167ad6f72d88..91b078f0618351f195a12e55cd55e5d07722d114 100644 (file)
@@ -8,13 +8,12 @@ import {formatError} from '../misc/errorUtils.js';
 // GJS finishes resolving this module.
 imports._promiseNative.setMainLoopHook(() => {
     // Queue starting the shell
-    GLib.idle_add(GLib.PRIORITY_DEFAULT, () => {
+    GLib.idle_add_once(GLib.PRIORITY_DEFAULT, () => {
         import('./main.js').then(main => main.start()).catch(e => {
             const error = new GLib.Error(
                 Gio.IOErrorEnum, Gio.IOErrorEnum.FAILED, formatError(e));
             global.context.terminate_with_error(error);
         });
-        return GLib.SOURCE_REMOVE;
     });
 
     // Run the meta context's main loop
index d3d7ef8bea2b877895cb426239af730249016317..644409e351048e54e048b700cc8512862787ca1e 100644 (file)
@@ -282,7 +282,7 @@ const Key = GObject.registerClass({
 
     _press(button) {
         if (button === this.keyButton) {
-            this._pressTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT,
+            this._pressTimeoutId = GLib.timeout_add_once(GLib.PRIORITY_DEFAULT,
                 KEY_LONG_PRESS_TIME,
                 () => {
                     this._pressTimeoutId = 0;
@@ -296,8 +296,6 @@ const Key = GObject.registerClass({
                         this.keyButton.fake_release();
                         this._showSubkeys();
                     }
-
-                    return GLib.SOURCE_REMOVE;
                 });
         }
 
@@ -1379,10 +1377,9 @@ export const Keyboard = GObject.registerClass({
         }
 
         if (!this._showIdleId) {
-            this._showIdleId = GLib.idle_add(GLib.PRIORITY_DEFAULT_IDLE, () => {
+            this._showIdleId = GLib.idle_add_once(GLib.PRIORITY_DEFAULT_IDLE, () => {
                 this.open(Main.layoutManager.focusIndex);
                 this._showIdleId = 0;
-                return GLib.SOURCE_REMOVE;
             });
             GLib.Source.set_name_by_id(this._showIdleId, '[gnome-shell] this.open');
         }
@@ -1716,12 +1713,11 @@ export const Keyboard = GObject.registerClass({
             return;
         }
 
-        this._keyboardRestingId = GLib.timeout_add(GLib.PRIORITY_DEFAULT,
+        this._keyboardRestingId = GLib.timeout_add_once(GLib.PRIORITY_DEFAULT,
             KEYBOARD_REST_TIME,
             () => {
                 this._clearKeyboardRestTimer();
                 this._open();
-                return GLib.SOURCE_REMOVE;
             });
         GLib.Source.set_name_by_id(this._keyboardRestingId, '[gnome-shell] this._clearKeyboardRestTimer');
     }
@@ -1751,12 +1747,11 @@ export const Keyboard = GObject.registerClass({
             return;
         }
 
-        this._keyboardRestingId = GLib.timeout_add(GLib.PRIORITY_DEFAULT,
+        this._keyboardRestingId = GLib.timeout_add_once(GLib.PRIORITY_DEFAULT,
             KEYBOARD_REST_TIME,
             () => {
                 this._clearKeyboardRestTimer();
                 this._close();
-                return GLib.SOURCE_REMOVE;
             });
         GLib.Source.set_name_by_id(this._keyboardRestingId, '[gnome-shell] this._clearKeyboardRestTimer');
     }
@@ -2186,10 +2181,9 @@ class KeyboardController extends Signals.EventEmitter {
                             this._surroundingUpdateTimeoutId = 0;
                         }
                         this._surroundingUpdateTimeoutId =
-                            GLib.timeout_add(GLib.PRIORITY_DEFAULT, KEY_RELEASE_TIMEOUT, () => {
+                            GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, KEY_RELEASE_TIMEOUT, () => {
                                 func(text, cursor, cursor);
                                 this._surroundingUpdateTimeoutId = 0;
-                                return GLib.SOURCE_REMOVE;
                             });
                     }
                 });
index 02cda39fd7456f861b9e6770823d53bc1fdf0122..41f4940f54788414fa83067cecbcdcc336e9a151 100644 (file)
@@ -1379,10 +1379,9 @@ class LookingGlass extends St.BoxLayout {
         gcButton.connect('clicked', () => {
             gcButton.child.icon_name = 'user-trash-symbolic';
             System.gc();
-            this._timeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 500, () => {
+            this._timeoutId = GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, 500, () => {
                 gcButton.child.icon_name = 'user-trash-full-symbolic';
                 this._timeoutId = 0;
-                return GLib.SOURCE_REMOVE;
             });
             GLib.Source.set_name_by_id(
                 this._timeoutId,
index 6e2c74aa9762459b2f59b99a5bb4040d632b04f6..4536436c1b9555df153898021413b364c74f9735 100644 (file)
@@ -1321,7 +1321,7 @@ class ZoomRegion {
             this._updateMousePosition();
 
         this._clearScrollContentsTimer();
-        this._scrollContentsTimerId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, POINTER_REST_TIME, () => {
+        this._scrollContentsTimerId = GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, POINTER_REST_TIME, () => {
             this._followingCursor = false;
             if (this._xDelayed != null && this._yDelayed != null) {
                 this._scrollContentsToDelayed(this._xDelayed, this._yDelayed);
@@ -1330,8 +1330,6 @@ class ZoomRegion {
             }
 
             this._scrollContentsTimerId = 0;
-
-            return GLib.SOURCE_REMOVE;
         });
 
         // Determine whether the system mouse pointer is over this zoom region.
index 90e78a197a34e8dff3ff65d87a31bd5791fcd89d..1b917f988186dd39d186dfb1e85fc4babad4e471 100644 (file)
@@ -311,10 +311,9 @@ async function _initializeUI() {
     endSessionDialog = new EndSessionDialog.EndSessionDialog();
 
     // We're ready for the session manager to move to the next phase
-    GLib.idle_add(GLib.PRIORITY_DEFAULT, () => {
+    GLib.idle_add_once(GLib.PRIORITY_DEFAULT, () => {
         Shell.util_sd_notify();
         global.context.notify_ready();
-        return GLib.SOURCE_REMOVE;
     });
 
     _startDate = new Date();
@@ -998,10 +997,9 @@ export function queueDeferredWork(workId) {
     if (data.actor.mapped) {
         _queueBeforeRedraw(workId);
     } else if (_deferredTimeoutId === 0) {
-        _deferredTimeoutId = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, DEFERRED_TIMEOUT_SECONDS, () => {
+        _deferredTimeoutId = GLib.timeout_add_seconds_once(GLib.PRIORITY_DEFAULT, DEFERRED_TIMEOUT_SECONDS, () => {
             _runAllDeferredWork();
             _deferredTimeoutId = 0;
-            return GLib.SOURCE_REMOVE;
         });
         GLib.Source.set_name_by_id(_deferredTimeoutId, '[gnome-shell] _runAllDeferredWork');
     }
index bf8725f1662cbd14d603c362befde5127aae9d17..d4f7cded8c8c7add88fb988cd062c65dd7cc7792 100644 (file)
@@ -366,10 +366,9 @@ export class Notification extends GObject.Object {
                 delete this._updateDatetimeId;
             } else if (!this._updateDatetimeId) {
                 this._updateDatetimeId =
-                    GLib.idle_add(GLib.PRIORITY_DEFAULT, () => {
+                    GLib.idle_add_once(GLib.PRIORITY_DEFAULT, () => {
                         delete this._updateDatetimeId;
                         this.datetime = GLib.DateTime.new_now_local();
-                        return GLib.SOURCE_REMOVE;
                     });
             }
         });
@@ -993,7 +992,7 @@ export const MessageTray = GObject.registerClass({
             // We wait for a longer period if the notification popped up where the mouse pointer was already positioned.
             // That gives the user more time to mouse away from the notification and mouse back in in order to expand it.
             const timeout = this._useLongerNotificationLeftTimeout ? LONGER_HIDE_TIMEOUT : HIDE_TIMEOUT;
-            this._notificationLeftTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, timeout, this._onNotificationLeftTimeout.bind(this));
+            this._notificationLeftTimeoutId = GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, timeout, this._onNotificationLeftTimeout.bind(this));
             GLib.Source.set_name_by_id(this._notificationLeftTimeoutId, '[gnome-shell] this._onNotificationLeftTimeout');
         }
     }
@@ -1022,7 +1021,7 @@ export const MessageTray = GObject.registerClass({
             x < this._notificationLeftMouseX + MOUSE_LEFT_ACTOR_THRESHOLD &&
             x > this._notificationLeftMouseX - MOUSE_LEFT_ACTOR_THRESHOLD) {
             this._notificationLeftMouseX = -1;
-            this._notificationLeftTimeoutId = GLib.timeout_add(
+            this._notificationLeftTimeoutId = GLib.timeout_add_once(
                 GLib.PRIORITY_DEFAULT,
                 LONGER_HIDE_TIMEOUT,
                 this._onNotificationLeftTimeout.bind(this));
@@ -1034,7 +1033,6 @@ export const MessageTray = GObject.registerClass({
             this._updateNotificationTimeout(0);
             this._updateState();
         }
-        return GLib.SOURCE_REMOVE;
     }
 
     // All of the logic for what happens when occurs here; the various
@@ -1208,7 +1206,7 @@ export const MessageTray = GObject.registerClass({
         }
         if (timeout > 0) {
             this._notificationTimeoutId =
-                GLib.timeout_add(GLib.PRIORITY_DEFAULT, timeout,
+                GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, timeout,
                     this._notificationTimeout.bind(this));
             GLib.Source.set_name_by_id(this._notificationTimeoutId, '[gnome-shell] this._notificationTimeout');
         }
@@ -1235,7 +1233,6 @@ export const MessageTray = GObject.registerClass({
 
         this._lastSeenMouseX = x;
         this._lastSeenMouseY = y;
-        return GLib.SOURCE_REMOVE;
     }
 
     _hideNotification(animate) {
index e1f8d85fc7ee3b00d21d634a01c1b0398e416e7a..47c840a085bbdf2619c527a3e854f8d5b5161ac6 100644 (file)
@@ -106,7 +106,7 @@ class OsdWindow extends Clutter.Actor {
 
         if (this._hideTimeoutId)
             GLib.source_remove(this._hideTimeoutId);
-        this._hideTimeoutId = GLib.timeout_add(
+        this._hideTimeoutId = GLib.timeout_add_once(
             GLib.PRIORITY_DEFAULT, HIDE_TIMEOUT, this._hide.bind(this));
         GLib.Source.set_name_by_id(this._hideTimeoutId, '[gnome-shell] this._hide');
     }
@@ -130,7 +130,6 @@ class OsdWindow extends Clutter.Actor {
                 global.compositor.enable_unredirect();
             },
         });
-        return GLib.SOURCE_REMOVE;
     }
 
     _reset() {
index 82f83f9229318349584ed2ed307f4f7704c0b74b..d3d64ae71b6fc2fded0f2e4c0ec515dc6f56319c 100644 (file)
@@ -309,7 +309,7 @@ export class Overview extends Signals.EventEmitter {
 
         if (targetIsWindow) {
             this._lastHoveredWindow = dragEvent.targetActor._delegate.metaWindow;
-            this._windowSwitchTimeoutId = GLib.timeout_add(
+            this._windowSwitchTimeoutId = GLib.timeout_add_once(
                 GLib.PRIORITY_DEFAULT,
                 DND_WINDOW_SWITCH_TIMEOUT,
                 () => {
@@ -318,7 +318,6 @@ export class Overview extends Signals.EventEmitter {
                         this._windowSwitchTimestamp);
                     this.hide();
                     this._lastHoveredWindow = null;
-                    return GLib.SOURCE_REMOVE;
                 });
             GLib.Source.set_name_by_id(this._windowSwitchTimeoutId, '[gnome-shell] Main.activateWindow');
         }
index d836107a8ffb2fd5db541eb3c7259f09cca6db7a..e1d2b8bc53c7dd5a62fd82311b479927ac97bfc7 100644 (file)
@@ -233,7 +233,7 @@ class ActivitiesButton extends PanelMenu.Button {
 
         if (this._xdndTimeOut !== 0)
             GLib.source_remove(this._xdndTimeOut);
-        this._xdndTimeOut = GLib.timeout_add(GLib.PRIORITY_DEFAULT, BUTTON_DND_ACTIVATION_TIMEOUT, () => {
+        this._xdndTimeOut = GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, BUTTON_DND_ACTIVATION_TIMEOUT, () => {
             this._xdndToggleOverview();
         });
         GLib.Source.set_name_by_id(this._xdndTimeOut, '[gnome-shell] this._xdndToggleOverview');
@@ -266,7 +266,6 @@ class ActivitiesButton extends PanelMenu.Button {
 
         GLib.source_remove(this._xdndTimeOut);
         this._xdndTimeOut = 0;
-        return GLib.SOURCE_REMOVE;
     }
 });
 
index 9af1f791a6f3268ea99b217f204f00dc3d1f9e8c..515dc827995f4d4942108c961cfaf82fb1c441c3 100644 (file)
@@ -261,13 +261,12 @@ export class ScreenShield extends Signals.EventEmitter {
             const lockTimeout = Math.max(
                 adjustAnimationTime(STANDARD_FADE_TIME),
                 this._settings.get_uint(LOCK_DELAY_KEY) * 1000);
-            this._lockTimeoutId = GLib.timeout_add(
+            this._lockTimeoutId = GLib.timeout_add_once(
                 GLib.PRIORITY_DEFAULT,
                 lockTimeout,
                 () => {
                     this._lockTimeoutId = 0;
                     this.lock(false);
-                    return GLib.SOURCE_REMOVE;
                 });
             GLib.Source.set_name_by_id(this._lockTimeoutId, '[gnome-shell] this.lock');
         }
@@ -480,9 +479,8 @@ export class ScreenShield extends Signals.EventEmitter {
         if (params.fadeToBlack && params.animateFade) {
             // Take a beat
 
-            const id = GLib.timeout_add(GLib.PRIORITY_DEFAULT, MANUAL_FADE_TIME, () => {
+            const id = GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, MANUAL_FADE_TIME, () => {
                 this._activateFade(this._shortLightbox, MANUAL_FADE_TIME);
-                return GLib.SOURCE_REMOVE;
             });
             GLib.Source.set_name_by_id(id, '[gnome-shell] this._activateFade');
         } else {
index b1e5e58f7f99d90e7ce8f841a17d3cbb5702cb43..e0ec8b76acd8c95dc0423e00ac05dacc09ba8a6d 100644 (file)
@@ -94,7 +94,7 @@ class Tooltip extends St.Label {
         if (this._timeoutId)
             return;
 
-        this._timeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 300, () => {
+        this._timeoutId = GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, 300, () => {
             this.opacity = 0;
             this.show();
 
@@ -117,7 +117,6 @@ class Tooltip extends St.Label {
             });
 
             this._timeoutId = null;
-            return GLib.SOURCE_REMOVE;
         });
         GLib.Source.set_name_by_id(this._timeoutId, '[gnome-shell] tooltip.open');
     }
@@ -2836,9 +2835,8 @@ class SelectArea extends St.Widget {
         try {
             await this._grabHelper.grabAsync({actor: this});
         } finally {
-            GLib.idle_add(GLib.PRIORITY_DEFAULT, () => {
+            GLib.idle_add_once(GLib.PRIORITY_DEFAULT, () => {
                 this.destroy();
-                return GLib.SOURCE_REMOVE;
             });
         }
 
@@ -3083,9 +3081,8 @@ class PickPixel extends St.Widget {
         } finally {
             this._previewCursor.destroy();
 
-            GLib.idle_add(GLib.PRIORITY_DEFAULT, () => {
+            GLib.idle_add_once(GLib.PRIORITY_DEFAULT, () => {
                 this.destroy();
-                return GLib.SOURCE_REMOVE;
             });
         }
 
index d47354c0b21dd1623442cff443282c6bb3326d77..ea14d526c3c4a211aa5eee39633add3a84b506d7 100644 (file)
@@ -37,9 +37,8 @@ import {loadInterfaceXML} from '../misc/fileUtils.js';
  */
 export function sleep(milliseconds) {
     return new Promise(resolve => {
-        const id = GLib.timeout_add(GLib.PRIORITY_DEFAULT, milliseconds, () => {
+        const id = GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, milliseconds, () => {
             resolve();
-            return GLib.SOURCE_REMOVE;
         });
         GLib.Source.set_name_by_id(id, '[gnome-shell] sleep');
     });
index 3c171b43f777c56c25bf350826702bd041ce89c6..897bae5b9abf909de98cf6bd4540aeb6df38d622 100644 (file)
@@ -727,7 +727,6 @@ export const SearchResultsView = GObject.registerClass({
     _onSearchTimeout() {
         this._searchTimeoutId = 0;
         this._doSearch();
-        return GLib.SOURCE_REMOVE;
     }
 
     setTerms(terms) {
@@ -759,7 +758,7 @@ export const SearchResultsView = GObject.registerClass({
         this._updateSearchProgress();
 
         if (this._searchTimeoutId === 0)
-            this._searchTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 150, this._onSearchTimeout.bind(this));
+            this._searchTimeoutId = GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, 150, this._onSearchTimeout.bind(this));
 
         this._highlighter = new Highlighter(this._terms);
 
index c098a41e121223f23f7a68a5258c72e822c2965a..7747963691611e5295d0a4abd3bdffcbeace8201 100644 (file)
@@ -94,15 +94,13 @@ class ATIndicator extends PanelMenu.Button {
         const items = this.menu._getMenuItems();
 
         this.visible = alwaysShow || items.some(f => !!f.state);
-
-        return GLib.SOURCE_REMOVE;
     }
 
     _queueSyncMenuVisibility() {
         if (this._syncMenuVisibilityIdle)
             return;
 
-        this._syncMenuVisibilityIdle = GLib.idle_add(GLib.PRIORITY_DEFAULT, this._syncMenuVisibility.bind(this));
+        this._syncMenuVisibilityIdle = GLib.idle_add_once(GLib.PRIORITY_DEFAULT, this._syncMenuVisibility.bind(this));
         GLib.Source.set_name_by_id(this._syncMenuVisibilityIdle, '[gnome-shell] this._syncMenuVisibility');
     }
 
index 3399b9f9e06bf343d846d34dc50fa7026f4188f0..aff6d6f5249d2c4242b9e037c268838e059676ca 100644 (file)
@@ -113,12 +113,11 @@ const BackgroundAppMenuItem = GObject.registerClass({
     async _quitApp() {
         this._spinner.play();
         this._spinnerTimeoutId =
-            GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, SPINNER_TIMEOUT,
+            GLib.timeout_add_seconds_once(GLib.PRIORITY_DEFAULT, SPINNER_TIMEOUT,
                 () => {
                     // Assume the quit request has failed, stop the spinner
                     this._spinner.stop();
                     delete this._spinnerTimeoutId;
-                    return GLib.SOURCE_REMOVE;
                 });
 
         try {
index b8a5ea1d45fd1741f2fbb8e5ffce8eed37e00abb..a9cd1437b5280385db7393d98a72dffe4900e9b3 100644 (file)
@@ -176,10 +176,9 @@ const BtClient = GObject.registerClass({
     _queueDevicesChanged() {
         if (this._devicesChangedId)
             return;
-        this._devicesChangedId = GLib.idle_add(GLib.PRIORITY_DEFAULT, () => {
+        this._devicesChangedId = GLib.idle_add_once(GLib.PRIORITY_DEFAULT, () => {
             delete this._devicesChangedId;
             this.emit('devices-changed');
-            return GLib.SOURCE_REMOVE;
         });
     }
 
index 7974a1b062fc5e7ad7794a3ad26ef26c0be13a69..3bcdcbb885bca82f8dc6d44d27931a505ca0429d 100644 (file)
@@ -187,7 +187,6 @@ export const ScreenSharingIndicator = GObject.registerClass({
     _hideIndicator() {
         this.hide();
         delete this._hideIndicatorId;
-        return GLib.SOURCE_REMOVE;
     }
 
     _sync() {
@@ -210,7 +209,7 @@ export const ScreenSharingIndicator = GObject.registerClass({
                 const timeUntilHideUs =
                     MIN_SHARED_INDICATOR_VISIBLE_TIME_US - timeSinceVisibleUs;
                 this._hideIndicatorId =
-                    GLib.timeout_add(GLib.PRIORITY_DEFAULT,
+                    GLib.timeout_add_once(GLib.PRIORITY_DEFAULT,
                         timeUntilHideUs / GLib.TIME_SPAN_MILLISECOND,
                         () => this._hideIndicator());
             }
index c9b42089c00b580504641ed4ee5cb1257ac10b1d..0fe877657cbe336cf63cd09b38d172c660db7d2e 100644 (file)
@@ -181,7 +181,7 @@ class AuthRobot extends Signals.EventEmitter {
             return;
 
         this._enrolling = true;
-        GLib.idle_add(GLib.PRIORITY_DEFAULT,
+        GLib.idle_add_once(GLib.PRIORITY_DEFAULT,
             this._enrollDevicesIdle.bind(this));
     }
 
@@ -190,7 +190,7 @@ class AuthRobot extends Signals.EventEmitter {
 
         const dev = devices.shift();
         if (dev === undefined)
-            return GLib.SOURCE_REMOVE;
+            return;
 
         try {
             await this._client.enrollDevice(dev.Uid, Policy.DEFAULT);
@@ -202,13 +202,12 @@ class AuthRobot extends Signals.EventEmitter {
             this._enrolling = this._devicesToEnroll.length > 0;
 
             if (this._enrolling) {
-                GLib.idle_add(GLib.PRIORITY_DEFAULT,
+                GLib.idle_add_once(GLib.PRIORITY_DEFAULT,
                     this._enrollDevicesIdle.bind(this));
             }
         } catch (error) {
             this.emit('enroll-failed', null, error);
         }
-        return GLib.SOURCE_REMOVE;
     }
 }
 
index 4f57ebb3a0f075e6670f83652fa06761b784b4d5..0dbb2cefeb46fb069e7434d9ce25cdf76b0aca92 100644 (file)
@@ -194,10 +194,9 @@ const StreamSlider = GObject.registerClass({
 
         const volumeChanged = this._stream.volume !== prevVolume;
         if (volumeChanged && !this._notifyVolumeChangeId && !this._inDrag) {
-            this._notifyVolumeChangeId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 30, () => {
+            this._notifyVolumeChangeId = GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, 30, () => {
                 this._notifyVolumeChange();
                 this._notifyVolumeChangeId = 0;
-                return GLib.SOURCE_REMOVE;
             });
             GLib.Source.set_name_by_id(this._notifyVolumeChangeId,
                 '[gnome-shell] this._notifyVolumeChangeId');
index b4cb9d57f1571b151d94e51b5b76df7d667e44eb..2cd5ab7ed6aa4f120188f8f00f8180bf67746e7f 100644 (file)
@@ -158,12 +158,11 @@ export const SwitcherPopup = GObject.registerClass({
 
         // We delay showing the popup so that fast Alt+Tab users aren't
         // disturbed by the popup briefly flashing.
-        this._initialDelayTimeoutId = GLib.timeout_add(
+        this._initialDelayTimeoutId = GLib.timeout_add_once(
             GLib.PRIORITY_DEFAULT,
             POPUP_DELAY_TIMEOUT,
             () => {
                 this._showImmediately();
-                return GLib.SOURCE_REMOVE;
             });
         GLib.Source.set_name_by_id(this._initialDelayTimeoutId, '[gnome-shell] Main.osdWindow.cancel');
         return true;
@@ -294,14 +293,13 @@ export const SwitcherPopup = GObject.registerClass({
         if (this._motionTimeoutId !== 0)
             GLib.source_remove(this._motionTimeoutId);
 
-        this._motionTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, DISABLE_HOVER_TIMEOUT, this._mouseTimedOut.bind(this));
+        this._motionTimeoutId = GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, DISABLE_HOVER_TIMEOUT, this._mouseTimedOut.bind(this));
         GLib.Source.set_name_by_id(this._motionTimeoutId, '[gnome-shell] this._mouseTimedOut');
     }
 
     _mouseTimedOut() {
         this._motionTimeoutId = 0;
         this.mouseActive = true;
-        return GLib.SOURCE_REMOVE;
     }
 
     _isActorOutside(actor) {
@@ -312,13 +310,12 @@ export const SwitcherPopup = GObject.registerClass({
         if (this._noModsTimeoutId !== 0)
             GLib.source_remove(this._noModsTimeoutId);
 
-        this._noModsTimeoutId = GLib.timeout_add(
+        this._noModsTimeoutId = GLib.timeout_add_once(
             GLib.PRIORITY_DEFAULT,
             NO_MODS_TIMEOUT,
             () => {
                 this._finish(global.display.get_current_time_roundtrip());
                 this._noModsTimeoutId = 0;
-                return GLib.SOURCE_REMOVE;
             });
     }
 
index fdd79705c34efffe4aff39a2e023878ee029d181..92d6cf8aa1413bf314b7334e2458fcabe0bea705 100644 (file)
@@ -297,10 +297,9 @@ class WorkspaceTracker {
         if (workspace._keepAliveId)
             GLib.source_remove(workspace._keepAliveId);
 
-        workspace._keepAliveId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, duration, () => {
+        workspace._keepAliveId = GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, duration, () => {
             workspace._keepAliveId = 0;
             this._queueCheckWorkspaces();
-            return GLib.SOURCE_REMOVE;
         });
         GLib.Source.set_name_by_id(workspace._keepAliveId, '[gnome-shell] this._queueCheckWorkspaces');
     }
@@ -308,12 +307,11 @@ class WorkspaceTracker {
     _windowRemoved(workspace, window) {
         workspace._lastRemovedWindow = window;
         this._queueCheckWorkspaces();
-        const id = GLib.timeout_add(GLib.PRIORITY_DEFAULT, LAST_WINDOW_GRACE_TIME, () => {
+        const id = GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, LAST_WINDOW_GRACE_TIME, () => {
             if (workspace._lastRemovedWindow === window) {
                 workspace._lastRemovedWindow = null;
                 this._queueCheckWorkspaces();
             }
-            return GLib.SOURCE_REMOVE;
         });
         GLib.Source.set_name_by_id(id, '[gnome-shell] this._queueCheckWorkspaces');
     }
@@ -1890,10 +1888,9 @@ export class WindowManager {
         this.actionMoveWorkspace(ws);
 
         this._canScroll = false;
-        GLib.timeout_add(GLib.PRIORITY_DEFAULT,
+        GLib.timeout_add_once(GLib.PRIORITY_DEFAULT,
             SCROLL_TIMEOUT_TIME, () => {
                 this._canScroll = true;
-                return GLib.SOURCE_REMOVE;
             });
 
         return Clutter.EVENT_STOP;
index ccd23ae6b13b3a5879f9cba4c399fc82e94911af..5c043e4bed6400d1b9a950a65a84d171a5152c80 100644 (file)
@@ -1188,11 +1188,10 @@ class Workspace extends St.Widget {
         if (!win) {
             // Newly-created windows are added to a workspace before
             // the compositor finds out about them...
-            const id = GLib.idle_add(GLib.PRIORITY_DEFAULT, () => {
+            const id = GLib.idle_add_once(GLib.PRIORITY_DEFAULT, () => {
                 if (metaWin.get_compositor_private() &&
                     metaWin.get_workspace() === this.metaWorkspace)
                     this._doAddWindow(metaWin);
-                return GLib.SOURCE_REMOVE;
             });
             GLib.Source.set_name_by_id(id, '[gnome-shell] this._doAddWindow');
             return;
index 20313558a374d348861b62f10430ad8f38bf7cc4..9e65d3974778987d8402e8351dd5fd3b614e3097 100644 (file)
@@ -85,7 +85,7 @@ class WorkspaceSwitcherPopup extends Clutter.Actor {
 
         if (this._timeoutId !== 0)
             GLib.source_remove(this._timeoutId);
-        this._timeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, DISPLAY_TIMEOUT, this._onTimeout.bind(this));
+        this._timeoutId = GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, DISPLAY_TIMEOUT, this._onTimeout.bind(this));
         GLib.Source.set_name_by_id(this._timeoutId, '[gnome-shell] this._onTimeout');
 
         this._redisplayAllPopups();
@@ -101,7 +101,6 @@ class WorkspaceSwitcherPopup extends Clutter.Actor {
     }
 
     _onTimeout() {
-        GLib.source_remove(this._timeoutId);
         this._timeoutId = 0;
         this.ease({
             opacity: 0.0,
@@ -109,7 +108,6 @@ class WorkspaceSwitcherPopup extends Clutter.Actor {
             mode: Clutter.AnimationMode.EASE_OUT_QUAD,
             onComplete: () => this.destroy(),
         });
-        return GLib.SOURCE_REMOVE;
     }
 
     _onDestroy() {
index 40ac3630791dc6604acfc2de11a147f41da0a98e..79892f0f1570ddcd67a91cdcee6ca0e6130c2c24 100644 (file)
@@ -360,12 +360,11 @@ export const WorkspaceThumbnail = GObject.registerClass({
         if (!win) {
             // Newly-created windows are added to a workspace before
             // the compositor finds out about them...
-            const id = GLib.idle_add(GLib.PRIORITY_DEFAULT, () => {
+            const id = GLib.idle_add_once(GLib.PRIORITY_DEFAULT, () => {
                 if (!this._removed &&
                     metaWin.get_compositor_private() &&
                     metaWin.get_workspace() === this.metaWorkspace)
                     this._doAddWindow(metaWin);
-                return GLib.SOURCE_REMOVE;
             });
             GLib.Source.set_name_by_id(id, '[gnome-shell] this._doAddWindow');
             return;